export default {
  name: "guarantee",
  components: {
    resumeDetail: () => import("../../../component/resumeDetail/index.vue")
  },
  data() {
    return {
      loading: false,
      tableData: [],
      form: {
        companyid: "",
        pagenum: 1,
        pagesize: 10,
		idname:'employeeid2'
      },
      total: 0,
      dialogVisible: false,
      userid: "",
      nickName: ""
    };
  },
  created() {
    this.form.companyid = this.$route.params.companyid;
    this.getTableData();
  },
  methods: {
    goBack() {
      // this.$router.go(-1);
      this.$router.push({
        name: "employmentList"
      })
    },
    getTableData() {
      this.loading= true;
      this.$axios.post("/app/v1/platform/company/outSafeguardEmployeesList", this.form).then(res => {
        this.loading = false;
        if (res.data.code === 1) {
          this.tableData = res.data.data.list;
          this.total = parseInt(res.data.data.totalnum);
        } else {
          this.$message({
            message: res.data.message,
            type: "error"
          });
        }
      });
    },
    // 分页
    handleCurrentChange(val) {
      this.form.pagenum = val;
      this.getTableData();
    },
    handleSizeChange(val) {
      this.form.pagenum = 1;
      this.form.pagesize = val;
      this.getTableData();
    },
    // 查看会员详情
    handleClickNickName(row) {
      this.userid = row.userid;
      this.nickName = row.nickname;
      this.dialogVisible = true;
    },
    // 导出
    exportData() {
      this.$axios({
        method: 'post',
        url: '/app/v1/platform/statistic/outSafeguardEmployeesListOut',
        data: this.form,
        responseType: 'blob'
      }).then(res => {
        this.download(res)
      }).catch((error) => {
        this.$message({
          message: '导出失败',
          type: 'error'
        });
      })
    },
    download(res) {
      if (!res) {
        return
      }
      let bob = new Blob([res.data]);
      let fileName = (res.headers['content-disposition']).split('=')[1];
      fileName = decodeURI(fileName)
      let url = window.URL.createObjectURL(bob)
      let link = document.createElement('a')
      link.style.display = 'none'
      link.href = url
      link.setAttribute('download', fileName)
      document.body.appendChild(link)
      link.click()
    }
  }
};